#把前面存到的数据通过查询然后再写到一个新的数据库里，然后可以通过mongodb compass对新的数据库实现可视化

from Operate import House
from pymongo import MongoClient

client = MongoClient('localhost',27017)
database = client['house_test'] #连接数据库
set = database['set']  #新建集合

class HouseTest(object):

    def __init__(self):     #初始化函数
        client = MongoClient('localhost',27017)
        database = client.house_test
        self._housetest = database.house_test

    def insert_one(self,housetest):    #插入一个
        return self._housetest.insert_one(housetest)

    def insert_many(self,housetest):    #插入多个
        return self._housetest.insert_many(housetest)



if __name__ == '__main__':
    house = House()  #house对象
    housetest = HouseTest() #housetest对象

    print("---Find many---")
    many_house = house.find_many({'zl_地址': '古城丁区 -古城汇金'})#修改时需要这里的条件
    for s in many_house:
        print(s)
        housetest.insert_one(s)
    print("---------------\n")